<?php
include ("inc/head-html.php");
include_once("inc/session.php");
?>


  <script>
   function doInit(){
         formData =  [
                      { type:"settings" , labelWidth:80, inputWidth:250, position:"absolute"  },
	                    { type:"input" , name:"NOM", label:"Nom", labelAlign:"left", inputWidth:345, labelLeft:140, labelTop:5, inputLeft:220, inputTop:5  },
	                    { type:"input" , name:"VILLE", label:"Ville", labelAlign:"left", inputWidth:345, labelLeft:140, labelTop:30, inputLeft:220, inputTop:30  },
	                    { type:"input" , name:"SIGLE", label:"Sigle", labelAlign:"left", inputWidth:170, labelLeft:140, labelTop:55, inputLeft:220, inputTop:55  },
	                    { type:"input" , name:"NOM_CONTACT", label:"Nom Contact", labelAlign:"left", inputWidth:345, labelLeft:140, labelTop:80, inputLeft:220, inputTop:80  },
	                    { type:"input" , name:"ADRESSE_CONTACT", label:"Adresse", labelAlign:"left", inputWidth:400, labelLeft:140, labelTop:105, inputLeft:220, inputTop:105  },
                      { type:"input" , name:"MAIL_CONTACT", label:"email", labelAlign:"left", inputWidth:345, labelLeft:140, labelTop:130, inputLeft:220, inputTop:130  },
	                    { type:"input" , name:"TEL_CONTACT", label:"Tel", labelAlign:"left", inputWidth:170, labelLeft:140, labelTop:155, inputLeft:220, inputTop:155  },
                      { type:"combo" , name:"REF_LIGUE", label:"Ligue", labelWidth:250, labelAlign:"left", labelLeft:140, labelTop:180, inputLeft:220, inputTop:180  },
                      { type:"button" , name:"rem", label:"Supprimer Club", value:"Supprimer Club", width:"125", inputWidth:125, inputLeft:5, inputTop:5  },
                  		{ type:"button" , name:"add", label:"Ajouter Club", value:"Ajouter Club", width:"125", inputWidth:125, inputLeft:5, inputTop:30  },
	                    { type:"button" , name:"save", label:"Sauver", value:"Sauver", width:"125", inputWidth:125, inputLeft:5, inputTop:55 }
                  ] ;
   
          var dhxLayout2 = dhxMainLayout.cells("c").attachLayout("2U");
          dhxMainLayout.cells("b").attachObject("navig");
          var mygrid = dhxLayout2.cells("a").attachGrid();
          var myForm = dhxLayout2.cells("b").attachForm(formData);

          mygrid.setImagePath("codebase/imgs/");
          mygrid.setHeader("Nom,Ville,Sigle,Ligue,NOM_CONTACT,MAIL_CONTACT,ADRESSE_CONTACT,TEL_CONTACT");
          //mygrid.setHeader("NOM,VILLE);
          mygrid.setColumnIds("NOM,VILLE,SIGLE,REF_LIGUE,NOM_CONTACT,MAIL_CONTACT,ADRESSE_CONTACT,TEL_CONTACT");
          mygrid.setInitWidths("180,180,100,180,0,0,0,0");
          //mygrid.setColAlign("left");
          mygrid.setColTypes("ed,ed,ed,combo,ro,ro,ro,ro");
          mygrid.setSkin("modern");

 
          mygrid.init();
          var combo = mygrid.getColumnCombo(3);         
          combo.enableFilteringMode(false);       
          combo.loadXML("ligues_combo.php");   
                 
          mygrid.load("clubs.php");
          mygrid.enableSmartRendering(true); 
          mygrid.enableEditEvents(false, true, true);
          dp = new dataProcessor("clubs.php");
          dp.init(mygrid);   
           
          myForm.bind(mygrid);   
          
          var dhxCombo = myForm.getCombo("REF_LIGUE");
          dhxCombo.loadXML("ligues_combo.php");
          //mygrid.bind(dhxCombo, function(data, filter){
          //   return mygrid.cells(data, 0).getValue() == filter.text;
          //});       
          
           //---handler for buttons' clicks	

          myForm.attachEvent("onButtonClick", function(name, command){
           if(name=="add"){
              var newId = (new Date()).valueOf();
              mygrid.addRow(newId,"") ;
              mygrid.selectRow(mygrid.getRowIndex(newId),false,false,true);
            }
           if(name=="rem"){
              var selId = mygrid.getSelectedId();
              mygrid.deleteRow(selId); 
            }
           if(name=="save"){
                myForm.save();
            }
           
        });
          

    }
    
    function addRow(){
            var newId = (new Date()).valueOf();
            mygrid.addRow(newId,"") ;
            mygrid.selectRow(mygrid.getRowIndex(newId),false,false,true);
        }
    function removeRow(){
        var selId = mygrid.getSelectedId();
        mygrid.deleteRow(selId); 
        }   
  </script>
  
<div id="navig">  
<h2><a href="index.php">Gestion Compétition FSCF</a>-><a href="admin.php">Administration</a>-><a href="admin_clubs.php">Clubs</a></h2>
</div>
<?php

include ("inc/foot-html.php");
?>

 